package gold.digger;

import gold.utils.InputUtil;

import java.util.LinkedList;
import java.util.Queue;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC933 {
    public long startExecuteTime = System.currentTimeMillis();


    class RecentCounter {

        Queue<Integer> queue;

        public RecentCounter() {
            queue = new LinkedList<>();
        }

        public int ping(int t) {
            queue.offer(t);
            while (!queue.isEmpty() && t - queue.peek() > 3000) queue.poll();
            return queue.size();
        }
    }


    public void run() {
        RecentCounter re = new RecentCounter();
        System.out.println(re.ping(1));
        System.out.println(re.ping(100));
        System.out.println(re.ping(3001));
        System.out.println(re.ping(3002));
    }

    public static void main(String[] args) throws Exception {
        LC933 an = new LC933();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
